using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Tetris.Interfaces;

namespace Tetris.Blocks
{
    public class Tile : ITile
    {
        private readonly Texture2D _texture;
        private readonly Color _color;
        private Rectangle _rectangle;
        private Vector2 _position;
        private int _row;

        public Vector2 Position
        {
            get { return _position; }
            set { _position = value;
            _rectangle = new Rectangle((int)Position.X, (int)Position.Y, _texture.Width, _texture.Height);
            }
        }

        public Rectangle GetBoundaries()
        {
            return _rectangle;
        }

        public int GetRow()
        {
            return _row;
        }

        public void SetRow(int gridRow)
        {
            _row = gridRow;
        }

        public Tile(Texture2D texture, Color color)
        {
            _texture = texture;
            _color = color;
        }

        public void Initialize(IGameManager gameManager)
        {
        }

        public void Update(IGameManager gameManager)
        {
        }

        public void Draw(SpriteBatch spriteBatch, IGameManager gameManager, GameTime gameTime)
        {
            spriteBatch.Draw(_texture, _rectangle, _color);
        }
    }
}